package com.csgc.camera.widget.dialog

import android.app.Activity
import android.content.Context
import android.view.View
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.Toast

import com.csgc.camera.biz.vip.VipCenterActivity
import com.csgc.camera.storage.UserPreference
import com.csgc.camera.util.clickWithTrigger
import com.csgc.camera.widget.dialog.base.BottomDialog
import com.cysd.spsyxj.R
import com.hlyj.http.ad.NewGroMoreFeedAdManager
import com.hnyyac.ad.mds.utils.BaseAdConstants


class EditMaskDialog(val activity: Activity) {

    private lateinit var mDialog: BottomDialog
    private var layoutRemoveMask:View?=null
    var listener:OnItemClickListener?=null
    private var ivVipFlag:ImageView?=null
    private var frameLayout:FrameLayout?=null
    init {
        initDialog()
    }

    private fun initDialog(){
        mDialog = BottomDialog(activity).apply {
            setCustomView(R.layout.dialog_edit_mask)
            findViewById<View>(R.id.layout_add_new_mask)?.clickWithTrigger {
                dismissDialog()
                listener?.onAddMask()
            }
            ivVipFlag = findViewById(R.id.iv_vip_flag)
            layoutRemoveMask = findViewById(R.id.layout_remove_mask)
            layoutRemoveMask?.clickWithTrigger {
//                if (!UserPreference.instance.isVip()){
//                    VipCenterActivity.launch(context)
//                    return@clickWithTrigger
//                }
                dismissDialog()
                listener?.onRemoveMask()
            }
          frameLayout=findViewById(R.id.frame_content)
            val newGromoreFeedAd: NewGroMoreFeedAdManager = NewGroMoreFeedAdManager(activity , BaseAdConstants.FEEDAD_Id, frameLayout, 66)
            newGromoreFeedAd.loadAd()
        }


    }

    fun show(canRemoveMask:Boolean){
        if (canRemoveMask){
            layoutRemoveMask?.visibility = View.VISIBLE
        }else{
            layoutRemoveMask?.visibility = View.GONE
        }
        if (UserPreference.instance.isVip()){
            ivVipFlag?.visibility = View.INVISIBLE
        }else{
            ivVipFlag?.visibility = View.VISIBLE
        }
        mDialog.show()
    }
    fun dismissDialog(){
        mDialog.dismiss()
    }

    interface OnItemClickListener{
        fun onAddMask()
        fun onRemoveMask()
    }
}